require(["../conf/config.js"],function(){
	require(["jquery"],function($){
		$(function(){
			$.ajax({
				"url" : "../ajax/login_dl.json",
				"type" : "get",
				"dataType" : "json",
				"success" : function(){
					
				}
			})
		})
	})
})
window.onload=function(){
	let ipt = Array.from(document.getElementsByClassName("ipt"));			
	let btn = document.getElementsByClassName("dl")[0];
	ipt.forEach((item)=>{
		item.addEventListener("focus",function(){
			item.style["border-bottom"] = "#00f";
			item.style.color = "#00f";
			item.style["font-size"] = "12px";
			item.style["text-align"] = "top";			
		})
		item.addEventListener("blur",function(){
			item.style["border-bottom"] = "#eee";
			item.style.color = "#666";
			item.style["font-size"] = "20px";
			item.style["text-align"] = "bottom";			
		})
	})
	
	btn.addEventListener("click",function(){		
		let xhr = new XMLHttpRequest();
		xhr.open("get","../ajax/login_dl.json");
		xhr.send();
		xhr.onload=function(){
			let res = Array.from(JSON.parse(xhr.response));
			let index = res.findIndex(v => v.username === ipt[0].value);
			console.log(res)
			if(index>-1){
				if((res[index].password === ipt[1].value)&&(res[index].validation === ipt[2].value)){
					confirm("登陆成功！");
					console.log("hh")
				}
			}else{
				alert("输出有误，请先确认用户名是否正确")
			}
			
			// for(let i=0;i<ipt.length;i++){
			// 	if(i==0){
			// 		ipt[i].value
			// 	}
			// }
		}
	})
	
	
}